/* $Id: http.h,v 1.3 2006/03/15 03:49:16 jfb Exp $ */
/*
 * Copyright (c) 2003 Jean-Francois Brousseau <phrakt@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#ifndef _HTTP_CONN_H_
#define _HTTP_CONN_H_

#include <sys/types.h>
#include <sys/socket.h>

#include <netinet/in.h>

#include <limits.h>

#include <http/uri.h>
#include <http/msg.h>
#include <http/http.h>
#include <http/stat.h>


#define HTTP_CONN_INITBUFSIZE	1024



/* connection flags */
#define HTTP_CONN_KEEPALIVE	0x01



enum http_conn_state {
	HTTP_CONN_CLOSED,
	HTTP_CONN_OPEN,
};



http_conn_t*         http_conn_alloc    (int);
http_conn_t*         http_conn_getref   (http_conn_t *);
int                  http_conn_close    (http_conn_t *);
void                 http_conn_free     (http_conn_t *);
int                  http_conn_setflag  (http_conn_t *, int);
int                  http_conn_getflag  (http_conn_t *, int);
int                  http_conn_getfd    (http_conn_t *);
enum http_conn_state http_conn_getstate (http_conn_t *);
ssize_t              http_conn_recv     (http_conn_t *, void *, size_t);
http_msg_t*          http_conn_recvreq  (http_conn_t *, int);
ssize_t              http_conn_send     (http_conn_t *, const void *, size_t, int);
ssize_t              http_conn_sendfd   (http_conn_t *, int, size_t, int);
int                  http_conn_sendresp (http_conn_t *, http_msg_t *, int);



#endif /* _HTTP_CONN_H_ */
